<?php
	require_once(dirname(__FILE__)."/../core/database.php");

	// escapes a value safely (handles nulls)
	function safeParam($param){
  		if ($param == NULL){
    		return NULL;
	} else {
			$safe = mysql_real_escape_string($param);
    		return  $safe;
  		}
	}

	// escapes an entire array of values safely.
	// useful for escaping the $_get or $_post parameters array
	function safeParams(&$paramArray){
  		if ($paramArray == NULL)
    		return;
  		
  		foreach ($paramArray as &$param) {
    		if (is_array($param)) {
      		safeParams($param); // recursive...
    		} else { 
      		$param = safeParam($param);
    		}
  		} //$paramArray as &$param
		}

		safeParams($_GET);
		safeParams($_POST);
?>
